-
-
Notifications
You must be signed in to change notification settings - Fork 363
feat(actions): add nuget trusted publishing #6788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(actions): add nuget trusted publishing #6788
Conversation
|
Thanks for your PR, @micheloliveira-com. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR enhances the NuGet package publishing workflow by enabling GitHub’s OIDC token, integrating the NuGet/login@v1 action with a secrets-based username, and swapping the static API key for a dynamically obtained key to support NuGet’s Trusted Publishing feature. Sequence diagram for NuGet Trusted Publishing workflowsequenceDiagram
participant Workflow as "GitHub Actions Workflow"
participant NuGetLogin as "NuGet/login@v1 Action"
participant NuGetOrg as "NuGet.org"
participant Secrets as "GitHub Secrets"
Workflow->>NuGetLogin: Request login with secrets.NUGET_USER
NuGetLogin->>Secrets: Retrieve NUGET_USER
NuGetLogin->>NuGetOrg: Authenticate using OIDC token
NuGetOrg-->>NuGetLogin: Return temporary NUGET_API_KEY
NuGetLogin-->>Workflow: Output NUGET_API_KEY
Workflow->>NuGetOrg: Publish package using NUGET_API_KEY
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes and they look great!
Blocking issues:
- An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload. (link)
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `.github/workflows/pack.yml:25` </location>
<code_context>
uses: NuGet/login@v1
</code_context>
<issue_to_address>
**security (yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha):** An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload.
*Source: opengrep*
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
@ArgoZhang Hello. I think remaining without a SHA hash on Fixing a SHA may break in some future core NuGet changes as well. |
|
@micheloliveira-com thanks for your PR. We are completing the GitHub Star Achievement task, could you give this project a star? |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6788 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 739 739
Lines 31721 31721
Branches 4464 4464
=========================================
Hits 31721 31721
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements NuGet Trusted Publishing for enhanced security in package deployment, replacing traditional long-lived API keys with ephemeral tokens generated through OpenID Connect authentication.
- Add
id-token: writepermission to enable OIDC token generation - Integrate NuGet/login action to obtain temporary API keys using GitHub's trusted publishing
- Update environment variable to use the ephemeral API key from the login step
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| BootstrapBlazor.slnx | Add GitHub Actions workflow files to solution structure |
| .github/workflows/pack.yml | Implement NuGet trusted publishing with OIDC authentication |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
@source-ai review |
Link issues
fixed #6791
Summary By Copilot
Motivation
As described in the official announcement, the new Trusted Publishing feature greatly enhances package publishing security on NuGet.org.
We successfully tested this approach with our own NuGet library:
Required changes in this repository
secrets.NUGET_USERto this repository, using the NuGet.org username (profile name) of the package owner (BootstrapBlazor in this case).secrets.NUGET_API_KEYsecret can be removed from this repository and also from the NuGet.org account if it was only used here.One-time configuration on NuGet.org
According to the documentation:
BootstrapBlazor).dotnetcore).BootstrapBlazor)..github/workflows/(e.g.pack.yml).This setup eliminates the need for long-lived API keys and improves the overall security of the publishing process.
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Enable secure package publishing to NuGet.org by integrating the new Trusted Publishing workflow with id-token permissions and ephemeral credentials.
New Features:
Enhancements: